char *, a function is required. You can use the format function. The following details:
1: string and cstring between the same level
A: string to cstring
Cstring. Format ("% s", String. c_str ());
B: cstring to string
String S (cstring. getbuffer ());
Or
Cstring CSTR; string S = sctr;
Analysis: In a, the string is converted to the char type through the c_str function, and then to the ctring type through the char type.
Getbuffer in B is an internal fu
!Error Method 4:Codefile=m_head.getbuffer (Fnlen);//can be executed, but the value of CodeFile is emptyResources:CString converted to char?Cstring::getat this returns a CharIf it is to char *You can use Cstring:getbuffer to return a char *In fact, you can also force conversions:LPCTSTR PCH;CString Str ("123456");PCH = (LPCTSTR) str;The above code is actually the first to let the system perform a forced conversion results, so in fact a bit superfluous ...But it's safer to do this because char *pb
they occupy. CString belongs to the so-called wide character set, which accounts for two bytes of one character; the char type is a narrow character set and one char character takes one byte, so the conversion between them involves the conversion of the byte size. On the other hand, in MFC ctring, Unicode encoding is used by default, and Char is ANSI-encoded, and the storage size of a single character in two encodings is different.1. CString converte
P0String replace (int p0, int n0,const string s, int pos, int n);//delete p0 start n0 characters, then insert n characters from Pos in string s at P0String replace (int p0, int n0,int n, char c);//delete n0 characters starting p0, then insert n characters at P0 Insert:String insert (int p0,const string s);String insert (int p0,const string s, int pos, int n);//at p0 position Insert the first n characters of the Pos beginning in the string sString insert (int p0, int n, char c);//This functio
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.